<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<!DOCTYPE html>
<html>
<head>
    <title>备案审批</title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp"%>
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1>备案审批</h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
            <li class="active"><a href="#"><i class="active"></i>交易</a></li>
            <li class="active"><a href="#"><i class="active"></i>备案采购</a></li>
            <li class="active"><a href="#"><i class="active"></i>备案审批</a></li>
        </ol>
    </section>

    <section class="content">
        <div class=" box box-success">
            <div class="box-body">
                <form action="" method="post">
                <div class="input">
					<div class="textalign1">通用名：</div>
                    <div class="boxinput">
                        <input type="text" class="textinput" id="drugName" placeholder="通用名" />
                    </div>
                    <div class="textalign">药品编码：</div>
                    <div class="boxinput">
                        <input type="text" class="textinput" id="drugCode" placeholder="药品编码" />
                    </div>
                    <div class="textalign">生产企业：</div>
                    <div class="boxinput">
                        <input type="text" class="textinput" id="compName" placeholder="生产企业" />
                    </div>
               </div>
               <div class="input" style="margin-top:-5px">
                    <div class="textalign1">申请日期：</div>
                    <div class="boxinput">
                        <table style="width:100%;">
                            <tr>
                                <td style="width:46%">
                                    <input type="text" class="textinput" id="submitStartDate" placeholder="yyyy-MM-dd" data-provide="datepicker" data-date-fmt="yyyy-MM-dd" />
                                </td>
                                <td style="width:8%; text-align: center;">   
                                    -
                                </td>
                                <td style="width:46%">
                                    <input type="text" class="textinput" id="submitEndDate" placeholder="yyyy-MM-dd" data-provide="datepicker" data-date-fmt="yyyy-MM-dd" />
                                </td>
                            </tr> 
                        </table>
                    </div>
                    <div class="textalign">医疗机构：</div>
                    <div class="boxinput">
                        <input type="text" class="textinput" id="hospName" placeholder="医疗机构" />
                    </div>
                    <div class="textalign">
                        <button type="button" onclick="gridReload();" class="btn btn-success btn-sm" id="selectDicCompType">查询</button>
                    </div>
               </div>
               </form>
            </div>
        </div>
        <table class="jqgrid" id="gridlist"></table>
        <div id="gridpage"></div>
        
        <form action="${ctx}/bakpurchase/wsjAuditBak.html" method="post" id="Form">
            <input type="hidden" name="bakPurId" id="bakPurId">
        </form>
    </section>
    <%@ include file="/WEB-INF/component/commonJS.jsp"%>
    <script type="text/javascript">

//绑定回车
$('#drugName,#drugCode,#compName,#submitStartDate,#submitEndDate,#hospName').bind('keydown', function(event) {
    if (event.keyCode == "13") {
        $('#selectDicCompType').click();
    }
});	
$("#drugName").focus();//加载页面光标在第一个查询框内


        $(function () {
            $("#gridlist").jqGrid({
                url: "${ctx}/bakpurchase/getAuditBakList.html",
                mtype: "POST",
                datatype: "json",
                autowidth: true,
                autowidth: true,
                shrinkToFit:true,  
                autoScroll: true,
             //   height: 255,
                colNames: ['操作','采购价','申报采购数量', '药品编码', '通用名', '剂型', '规格', '转换系数', '单位', '材质', '生产企业', '配送企业', '医疗机构',  '备案类型', '申请日期'],
                colModel: [
                    { name: 'operate', width: 60, align: "center", sortable:false, 
                        formatter : function(val, opts, rowdata) {
                            return "<a href=\"javascript:auditBak('" + rowdata.bakPurId + "')\" style='background:url(${ctx}/lib/img/icon/icon.png) no-repeat 0px -40px' class='opIcon' title='审批'></a>";
                        }
                    },
					{ name: 'purPrice', index: 'purPrice', width: 80 ,align: 'right',
                        formatter:function(cellvalue, options, row) {
                            return formatAmount(cellvalue);
                        }
                    },
                    { name: 'purAmount', index: 'purAmount', width: 80 ,align: 'center'},
                    { name: 'drugCode', width: 120, align: 'center',sortable:false,
                        formatter:function(cellvalue, options, row) {
                            return drugInfoLink(cellvalue);
                        }
                    },
                    { name: 'drugName', index: 'drugName', width: 140,align: 'left', sortable:false },
                    { name: 'formName', index: 'formName', width: 80 ,align: 'center', sortable:false},
                    { name: 'specName', index: 'specName', width: 120 ,align: 'left', sortable:false},
                    { name: 'factor', index: 'factor', width: 80,align: 'center', sortable:false },
                    { name: 'unitName', index: 'unit', width: 80, align: 'center', sortable:false},
                    { name: 'materialName', index: 'materialName', width: 80, align: 'center', sortable:false},
                    { name: 'compName', index: 'compName', width: 180, sortable:false,
                        formatter:function(cellvalue, options, row) {
                            return compInfoLink(row.compCode, cellvalue, 1);
                        }
                    },
                    { name: 'delName', index: 'scCompname', width: 190, sortable:false,
                        formatter:function(cellvalue, options, row) {
                            return compInfoLink(row.delCode, cellvalue, 1);
                        }
                    },
                    { name: 'hospName', width: 190, sortable:false,
                        formatter:function(cellvalue, options, row) {
                            return hospInfoLink(row.hospCode, cellvalue, 1);
                        }
                    },
                    
                    { name: 'isLongtimePlan', index: 'isLongtimePlan', width: 80,align: 'center', sortable:false,
                        formatter : function(val, opts,rowdata) {
                            if (rowdata.isLongtimePlan == 1) {
                                return "长期备案";
                            }
                            return "临时备案";
                        }               
                    },
                    { name: 'bakSubmitDatetime', width: 100,align: 'center', sortable:false }
                ],
                rowNum: 20,
                rowList: [10, 20, 50, 100],
                rownumbers: true,
                pager: "#gridpage",
                viewrecords: true,
				gridComplete:function(){
					//序号列宽度自适应（参数为jqgridID）
					autoRNWidth("gridlist");
					//数据只有一条时默认选中（参数为jqgridID）
					selectByOneData("gridlist");
				},
                caption: "备案药品",
                jsonReader: {
                    repeatitems: false
                }
            });
            
            $("#gridlist").jqGrid('navGrid', '#gridpage', { add: false, edit: false, del: false, search: false, refresh: false });
            $(window).trigger("resize");        
			$("#gridlist").jqGrid("setGridHeight",create());
        });
        
        function auditBak(bakPurId){
            $("#bakPurId").val(bakPurId);
            $("#Form").submit();
        }
        
        function gridReload(){
            var drugCode = $.trim($("#drugCode").val());
            var drugName = $.trim($("#drugName").val());
            var compName = $.trim($("#compName").val());
            var hospName = $.trim($("#hospName").val());
            var submitStartDate = $("#submitStartDate").val();
            var submitEndDate = $("#submitEndDate").val();
            
            $("#gridlist").jqGrid('setGridParam',{
                datatype:'json',
                postData:{
                    "drugCode":drugCode,
                    "drugName":drugName,
                    "compName":compName,
                    "hospName":hospName,
                    "submitStartDate":submitStartDate,
                    "submitEndDate":submitEndDate
                },
                page : 1
            }).trigger("reloadGrid");
        }
    </script>
</body>
</html>